package com.spring.mvc.controller;

import com.spring.mvc.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0.0
 * @Date: 2022/6/16 21:18
 * @Author ZhuYouBin
 * @Description
 */
@Controller
public class JsonController {

    @RequestMapping("/json01")
    @ResponseBody
    public String json01() {
        return "{'json':'Use @ResponseBody Annotation.'}";
    }

    @RequestMapping("/json02")
    @ResponseBody
    public List<User> json02() {
        // 响应 List 集合数据
        List<User> list = new ArrayList<>();
        list.add(new User("zhangsan", "123456"));
        list.add(new User("lisi", "888999"));
        list.add(new User("wangwu", "666777"));
        return list;
    }

}
